package org.acghub.config.type;

import org.acghub.config.Type;
import org.acghub.config.TypeInstanceException;

/**
 * @Desc
 * @Author miyuki4j
 * @Date 2025/7/24/星期四 14:08
 * @Version 1.0
 */
public class DoubleType implements Type.SimpleType<Double> {

    @Override
    public String name() {
        return "double";
    }

    @Override
    public String javaInterface() {
        return "Double";
    }

    @Override
    public String defaultValue() {
        return ".0D";
    }

    @Override
    public Double instance(String value, String delimiters) throws TypeInstanceException {
        try {
            return Double.parseDouble(value);
        } catch (NumberFormatException nfe) {
            throw new TypeInstanceException("parse double value:" + value, nfe);
        }
    }

}
